#ifndef _GOVT_TRAITS_H
#define	_GOVT_TRAITS_H
/*******************************************************************************
 ** Name: traits.hpp                                                          **
 ** Description: WorldObject-derived container objects                        **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE within                  **
 ** this distribution or at $GOVTSANCT_WIKI/License-software.                 **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $HOME/LICENSE.                       **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Portions (c) 2012 Open Design Strategies, LLC.
// Modified $Date$ by $Author$
#define traits_h_ID    "$Id$"

#include <string>
#include "stat.hpp"

#define TRAIT_NONE      0x00000000
// Weapon Traits
// These possibly should be gotten from the DB
#define TRAIT_WPN_AP        (1<<1)	//!< armor piercing
#define TRAIT_WPN_BAL       (1<<2)	//!< balanced
#define TRAIT_WPN_DR        (1<<3)	//!< damage reduction
#define TRAIT_WPN_DEP       (1<<4)	//!< dependable
#define TRAIT_WPN_DUR       (1<<5)	//!< durable
#define TRAIT_WPN_ER        (1<<6)	//!< extended range
#define TRAIT_WPN_FRL       (1<<7)	//!< fast reload
#define TRAIT_WPN_FLA       (1<<8)	//!< flamable
#define TRAIT_WPN_FRA       (1<<9)	//!< frangible
#define TRAIT_WPN_GUI       (1<<10)	//!< guided
#define TRAIT_WPN_LR        (1<<11)	//!< long range
#define TRAIT_WPN_NV        (1<<12)	//!< nigh vision
#define TRAIT_WPN_OBA       (1<<13)	//!< off balance
#define TRAIT_WPN_REL       (1<<14)	//!< reliable
#define TRAIT_WPN_SR        (1<<15)	//!< short range
#define TRAIT_WPN_SRL       (1<<16)	//!< slow reload
#define TRAIT_WPN_SPL       (1<<17)
#define TRAIT_WPN_VOL       (1<<18)
#define TRAIT_WPN_URL       (1<<19)
#define TRAIT_WPN_UPG       (1<<20)	//!< upgradable
#define TRAIT_WPN_ACC       (1<<21)   // accurate
#define TRAIT_WPN_IMP       (1<<22)   // imprecise
#define TRAIT_WPN_BLK       (1<<23)   // bulky
#define TRAIT_WPN_DIS       (1<<24)   // discreet
#define TRAIT_WPN_SUP       (1<<25)   // suppressed
#define TRAIT_WPN_NSY       (1<<26)   // noisy
#define TRAIT_WPN_THB       (1<<27)   // threaded barrel
#define TRAIT_WPN_CMP       (1<<28)   // composite

// Vehicle Traits
#define TRAIT_VCL_EJS       (1<<1)    // ejection seats
#define TRAIT_VCL_TRA       (1<<2)   // traction
#define TRAIT_VCL_SEA       (1<<3)    // sealed
#define TRAIT_VCL_FLA       (1<<4)	//<! flammable
#define TRAIT_VCL_DEP       (1<<5)	//<! dependable
#define TRAIT_VCL_UDE       (1<<6)
#define TRAIT_VCL_ATV       (1<<7 )   // 4wheeler
#define TRAIT_VCL_ECM       (1<<8)    // electronic countermeasures
#define TRAIT_VCL_COM       (1<<9)   // satellite comm system
#define TRAIT_VCL_ARM       (1<<10)   // armored
#define TRAIT_VCL_FLY       (1<<11)   // flying
#define TRAIT_VCL_WPN       (1<<12)  // mounted weapons
#define TRAIT_VCL_UPG		(1<<13)	 // upgradeable

// Upgrades
#define UPGRADE_WPN_LASER	(1<<1)	//<! laser sight (incr acc)
#define UPGRADE_WPN_PORT	(1<<2)	//<! ported to reduce recoil
#define UPGRADE_WPN_THB		(1<<3)	//<! threaded barrel
#define UPGRADE_WPN_SCOPE	(1<<4)	//<! give LR attr
#define UPGRADE_WPN_STARLITE (1<<5)	//<! give NV attr
#define UPGRADE_WPN_STOCK	(1<<6)	//<! (acc and reduced recoil w/ BLK attr)
#define UPGRADE_WPN_REFORGE	(1<<7)	//<! give BAL attr
#define UPGRADE_WPN_POLY	(1<<8)	//<! give CMP attr
#define UPGRADE_WPN_BURST	(1<<9) 	//<! give burst capability
#define UPGRADE_WPN_AUTO	(1<<10)	//<! give full auto capability
#define UPGRADE_WPN_SAWED	(1<<11)	//<! sawed-off barrel - give SR attr
#define UPGRADE_WPN_SIGHTS	(1<<12)	//<! give ER attr

//TODO This may replace the defines above
namespace trait 
{
    enum class wpn {
	unknown, ap, bal, dr, dep, dur, er, frl, fla, fra, gui, lr, nv,
	oba, rel, sr, srl, spl, vol, url, upg, acc, imp, blk, dis, sup,
	nsy, thb, cmp
    };

    enum class vehicle {
        none, ejs, tra, sea, fla, dep, ude, atv, ecm,
        com, arm, fly, wpn, upg
    };
}


enum class TraitType { Weapon, Vehicle, Equipment, Upgrade, NPC, PC };

//! A trait is an adjective describing an item.
#pragma db object table("traits")
class Trait
{
public:
	Trait() { }

	// Getters
	const entity_t	ID() const { return id_; }
	const std::string &	Name() const { return name_; }
	const std::string & Desc() const { return desc_; }
	const std::string & Effect() const { return effect_desc_; }
	const std::string & Abbr() const { return abbr_; }
	const entity_t		Stat() const { return idstat_; }
	const int			Val() const { return val_; }
	const uint64_t		Mask() const { return mask_; }

	// Setters
	void	Name(const std::string & n) { name_ = n; }
	void	Desc(const std::string & d) { desc_ = d; }
	void	Effect(const std::string & e) { effect_desc_ = e; }
	void	Abbr(const std::string & a) { abbr_ = a; }
	void	Stat(const entity_t s) { idstat_ = s; }
	void	Val(const int v) { val_ = v; }
	void	Mask(const uint64_t m) { mask_ = m; }

private:
	friend class odb::access;

#pragma db id auto
	entity_t	id_;
#pragma db type ("VARCHAR(45)")
	std::string	name_;
#pragma db type ("VARCHAR(5)")
	std::string	abbr_;
	std::string	desc_;
#pragma db type ("VARCHAR(128)")
	std::string	effect_desc_;
	entity_t	idstat_;
	int			val_;
	uint64_t	mask_;
	TraitType	type_;
};


#endif	/* _OH_TRAITS_H */

